package cn.com.code.hwjs;

import java.util.Scanner;

/**
 * https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&rp=1&ru=%2Fexam%2Foj&qru=%2Fexam%2Foj&sourceUrl=%2Fexam%2Foj%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%25AC%2594%25E8%25AF%2595%25E7%259C%259F%25E9%25A2%2598%26topicId%3D37&difficulty=3&judgeStatus=&tags=&title=&gioEnter=menu
 *
 * @author zhengpei
 * @date 2022/5/4
 */
public class Hwjs63 {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    while (scan.hasNext()) {
      String data = scan.nextLine();
      int len = Integer.parseInt(scan.nextLine());
      double max = 0.0;
      String result = "";
      for (int i = 0; i < data.length() - len + 1; i++) {
        String str = data.substring(i, len + i);
        String str2 = str.replaceAll("[^CG]", "");
        double x = str2.length() * 1.0 / str.length();
        if (x > max) {
          result = str;
          max = x;
          if (x == 1.0) {
            break;
          }
        }
      }
      System.out.println(result);
    }
  }

}
